package com.wb.structual.proxy;

/**
 * @author 魏彪
 */
public class ProxySearcher implements Searcher {

    private RealSearcher realSearcher = new RealSearcher();

    private Logger logger = new Logger();

    private AccessValidator validator = new AccessValidator();

    @Override
    public String doSearch(String userId, String keyword) {
        // 身份校验
        if (validator.validate(userId)) {
            // 调用真实的查询
            String result = realSearcher.doSearch(userId, keyword);
            // 记录日志
            logger.log(userId);
            return result;
        }
        return null;
    }
}
